var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { getFileListSync } from '@mintlify/prebuild';
import { promises as _promises } from 'fs';
import { join } from 'path';
import { NEXT_PUBLIC_PATH } from '../../constants.js';
const { readFile } = _promises;
export const getSnippets = () => __awaiter(void 0, void 0, void 0, function* () {
    const snippetFilenames = getFileListSync(NEXT_PUBLIC_PATH).filter((file) => file.endsWith('.mdx') && file.startsWith('snippets/'));
    const promises = snippetFilenames.map((snippetFilename) => __awaiter(void 0, void 0, void 0, function* () {
        try {
            return {
                filename: '/' + snippetFilename,
                content: (yield readFile(join(NEXT_PUBLIC_PATH, snippetFilename))).toString(),
            };
        }
        catch (err) {
            console.warn(`Error reading snippet file ${snippetFilename}`);
            return;
        }
    }));
    return (yield Promise.all(promises)).filter(Boolean);
});
